package com.pureut.quality.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pureut.common.core.exception.GlobalException;
import com.pureut.common.core.utils.bean.BeanUtils;
import com.pureut.quality.domain.EportCorrectionNotice;
import com.pureut.quality.domain.ExternalAuditPlan;
import com.pureut.quality.domain.dto.EportCorrectionNoticeDto;
import com.pureut.quality.domain.dto.ExternalAuditPlanDto;
import com.pureut.quality.domain.vo.EportCorrectionNoticeVo;
import com.pureut.quality.domain.vo.ExternalAuditPlanVo;
import com.pureut.quality.domain.vo.SubmitVo;
import com.pureut.quality.mapper.EportCorrectionNoticeMapper;
import com.pureut.quality.mapper.ExternalAuditPlanMapper;
import com.pureut.quality.service.EportCorrectionNoticeService;
import com.pureut.quality.service.ExternalAuditPlanService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/***
 * 外审报告及整改通知
 * Author:C
 * Date:2023/01/19 17:15
 * @DESC
 */
@Service
public class EportCorrectionNoticeServiceImpl extends ServiceImpl<EportCorrectionNoticeMapper, EportCorrectionNotice> implements EportCorrectionNoticeService {

    @Resource
    EportCorrectionNoticeMapper eportCorrectionNoticeMapper;

    /**
     * 查询外审报告及整改通知列表
     * @param eportCorrectionNoticeVo
     * @return
     */
    @Override
    public List<EportCorrectionNoticeDto> listEportCorrectionNotice(EportCorrectionNoticeVo eportCorrectionNoticeVo) {
        List<EportCorrectionNoticeDto> list = eportCorrectionNoticeMapper.listEportCorrectionNotice(eportCorrectionNoticeVo);
        return list;
    }

    /**
     * 查看外审报告及整改通知
     * @param id
     * @return
     */
    @Override
    public EportCorrectionNoticeDto getInfo(Long id) {
        EportCorrectionNoticeDto list = eportCorrectionNoticeMapper.getInfo(id);
        return list;
    }

    /**
     * 新增外审报告及整改通知
     * @param eportCorrectionNoticeVo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean insertEportCorrectionNotice(EportCorrectionNoticeVo eportCorrectionNoticeVo) {
        EportCorrectionNotice eportCorrectionNotice = new EportCorrectionNotice();
        BeanUtils.copyProperties(eportCorrectionNoticeVo, eportCorrectionNotice);
        return save(eportCorrectionNotice);
    }

    /**
     * 修改外审报告及整改通知
     * @param eportCorrectionNoticeVo
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateEportCorrectionNotice(EportCorrectionNoticeVo eportCorrectionNoticeVo) {
        EportCorrectionNotice eportCorrectionNotice = new EportCorrectionNotice();
        BeanUtils.copyProperties(eportCorrectionNoticeVo, eportCorrectionNotice);
        eportCorrectionNotice.setId(eportCorrectionNoticeVo.getId());
        return updateById(eportCorrectionNotice);
    }

    /**
     * 删除外审报告及整改通知
     * @param ids
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean removeEportCorrectionNotice(String ids) {
        return removeById(ids);
    }
}
